<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>英雄列表</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        .main {
            max-width: 800px;
            width: 100%;
            margin: 0 auto;
            padding: 20px;
        }
        .main ul {
            list-style: none;
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            justify-content: center;
        }
        .main ul li {
            display: flex;
            flex-direction: column;
            align-items: center;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        .main ul li:hover {
            opacity: 0.8;
            transform: translateY(-5px);
            color: blue;
        }
        .img-container {
            width: 120px;
            height: 120px;
        }
        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 8px;
        }
        span {
            margin-top: 8px;
            font-size: 14px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="main">
        <ul></ul>
    </div>
    <script type="text/javascript">
        const uls = document.querySelector("ul");
        
        // 使用现代fetch API替代XMLHttpRequest
        fetch("https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js?v=58")
            .then(response => response.json())
            .then(data => {
                const heroes = data.hero;
                let html = "";
                heroes.forEach(hero => {
                    uls.innerHTML += `
                        <li onclick="detail('${hero.heroId}')">
                            <div class="img-container">
                                <img 
                                    src="https://game.gtimg.cn/images/lol/act/img/champion/${hero.alias}.png" 
                                    alt="${hero.name}"
                                    onerror="this.src='//via.placeholder.com/120x120?text=Image+Not+Found'"
                                >
                            </div>
                            <span>${hero.name}</span>
                        </li>
                    `;
                });
            })
            .catch(error => console.error("Error:", error));

        function detail(id) {
            window.location.href = `lol2.html?id=${id}`;
        }
    </script>
</body>
</html>